<!DOCTYPE html>
<html>
    <body>
        <h1>输入一个在五与十之间的数</h1>
        <input id="demo" type="text">
        <button onclick="fun()">提交</button>
        <p id="mess"></p>
        <script>
            function fun(){
                try{
                    var x = document.getElementById("demo").value;
                    if(x=="") throw "空！";
                    else if(isNaN(x)) throw "不是数字";
                    else if(x>10) throw "大了";
                    else if (x<5) throw "小了";

                }catch(err){
                    var y = document.getElementById("mess");
                    y.innerHTML = "错误：" + err;
                }
            }
        </script>
    </body>
</html>